package top.hudk.tank.model;


import top.hudk.tank.frame.AbstractGameFrame;

import java.awt.*;

/**
 * 作用：游戏界面中的元素抽象类
 *
 * @author hudk
 * @date 2020/9/10 22:34
 */
public abstract class GameObject {

    /**
     * 元素的位置左标 X
     */
    protected int x;
    /**
     * 元素的位置坐标 Y
     */
    protected int y;
    /**
     * 元素的长度尺寸
     */
    protected int width;
    /**
     * 元素的高度尺寸
     */
    protected int height;

    /**
     * 元素的矩形模型
     */
    protected Rectangle rect = new Rectangle();

    /**
     * 绘制
     * @param g
     */
    public abstract void paint(Graphics g, AbstractGameFrame gameFrame);


    /**
     * 设置坦克的位置
     * @param x
     * @param y
     */
    public void setPlace(int x, int y){
        this.x = x;
        this.y = y;
        rect.x = x;
        rect.y = y;
        rect.width = this.width;
        rect.height = this.height;
    }



    public int getX() {
        return x;
    }
    public void setX(int x) {
        this.x = x;
    }


    public int getY() {
        return y;
    }
    public void setY(int y) {
        this.y = y;
    }
    public int getWidth() {
        return this.width;
    }
    public void setWidth(int width){
        this.width = width;
    }

    public int getHeight() {
        return this.height;
    }

    public void setHeight(int height){
        this.height = height;
    }

    public Rectangle getRect() {
        return rect;
    }

    public void setRect(Rectangle rect){
        this.rect = rect;
    }

}
